﻿<Window x:Class="XsPub.PublishWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Properties="clr-namespace:XsPub.Properties"
        xmlns:XsPub="clr-namespace:XsPub"
        x:Name="_this"
        Title="XsPub Schema Publisher"
        Height="300"
        Width="650"
        Loaded="_this_Loaded">
    <Window.Resources>
        <Properties:Settings x:Key="Settings" />
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Label Grid.Row="0">Input Path:</Label>
        <TextBox x:Name="inputFilePath"
                 Grid.Row="0"
                 Grid.Column="1"
                 Text="{Binding Source={StaticResource Settings}, Path=Default.InputPath, Mode=TwoWay}"
                 Margin="4,4" />
        <Label Grid.Row="1">Output Path:</Label>
        <TextBox x:Name="outputPath"
                 Grid.Row="1"
                 Grid.Column="1"
                 Text="{Binding Source={StaticResource Settings}, Path=Default.OutputPath, Mode=TwoWay}"
                 Margin="4,4" />
        <Button x:Name="publish"
                HorizontalAlignment="Right"
                Grid.Row="2"
                Grid.Column="1"
                Padding="10,2"
                Margin="4,4"
                Click="publish_Click">
            Publish
        </Button>
        <Grid Grid.Row="3"
              Grid.Column="0"
              Grid.ColumnSpan="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="7*" />
                <ColumnDefinition Width="3*" />
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Row="0"
                       Grid.Column="1"
                       VerticalAlignment="Bottom"
                       Padding="10, 2"
                       FontWeight="Bold">
            Transformation Settings
            </TextBlock>
            <TreeView x:Name="_settings"
                      Grid.Row="1"
                      Grid.Column="0"
                      ItemsSource="{Binding ElementName=_this, Path=Settings.AllSettings}">
                <TreeView.ItemTemplate>
                    <HierarchicalDataTemplate>
                        <TextBlock Text="{Binding Path=DisplayName}" />
                    </HierarchicalDataTemplate>
                </TreeView.ItemTemplate>
            </TreeView>
            <!--<DataGrid x:Name="_settings"
                Grid.Row="1"
                      Grid.Column="0"
                      AutoGenerateColumns="False"
                      ItemsSource="{Binding ElementName=_this, Path=Settings.AllSettings}"
                      AreRowDetailsFrozen="True">
                <DataGrid.Columns>
                    <DataGridTemplateColumn Header="Setting Name"
                                            IsReadOnly="True"
                                            MinWidth="100">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Path=DisplayName}"
                                           ToolTipService.ToolTip="{Binding Path=Description}" />
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTemplateColumn Header="Setting Value"
                                            MinWidth="90">
                        <DataGridTemplateColumn.CellTemplateSelector>
                            <XsPub:GenericValueTemplateSelector>
                                <XsPub:GenericValueTemplateSelector.Templates>
                                    <XsPub:DefaultTemplateList BindingPath="CurrentValue" />
                                </XsPub:GenericValueTemplateSelector.Templates>
                            </XsPub:GenericValueTemplateSelector>
                        </DataGridTemplateColumn.CellTemplateSelector>
                    </DataGridTemplateColumn>
                </DataGrid.Columns>
            </DataGrid>-->
            <TextBlock Grid.Row="0"
                       Grid.Column="1"
                       VerticalAlignment="Bottom"
                       Padding="10, 2"
                       FontWeight="Bold">
            Available Transformations
            </TextBlock>
            <DataGrid x:Name="_factories"
                Grid.Row="1"
                      Grid.Column="1"
                      IsReadOnly="True"
                      ItemsSource="{Binding ElementName=_this, Path=Factories}"
                      MouseDoubleClick="DataGrid_MouseDoubleClick">
                <DataGrid.Columns>
                    <DataGridTextColumn Header="Name"
                                        Binding="{Binding Path=DisplayName, Mode=OneWay}" />
                    <DataGridTemplateColumn Header="Description" IsReadOnly="True">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBox TextWrapping="Wrap"
                                         Text="{Binding Path=Description, Mode=OneWay}"/>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>                   
                </DataGrid.Columns>
            </DataGrid>
        </Grid>
        <StackPanel
            Grid.Row="4"
            Grid.Column="0"
            Grid.ColumnSpan="2"
            Orientation="Horizontal"
            HorizontalAlignment="Left">
            <Button x:Name="_resetButton"
                    Margin="5,5"
                    Click="_resetButton_Click">Reset </Button>
            <Button x:Name="_loadButton" Margin="5,5"
                    Click="_loadButton_Click">Load</Button>
            <Button x:Name="_saveButton"
                    Margin="5,5"
                    Click="_saveButton_Click">Save</Button>
        </StackPanel>
    </Grid>
</Window>
